﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HZ.MBSM.DBUtility;

public partial class Manage_CompanyGMPUpdate : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string strSql, Id = SysFun.IsSQL(SysFun.ToTrim(MsgBox.JieMi_Decrypt(Request.QueryString["ID"])));
        System.Collections.Generic.List<HZ.MBSM.DAL.AccountType> _AccountType = new System.Collections.Generic.List<HZ.MBSM.DAL.AccountType>();
        _AccountType.Add(HZ.MBSM.DAL.AccountType.enumAdmin);
        _AccountType.Add(HZ.MBSM.DAL.AccountType.enumAttorney);
        _AccountType.Add(HZ.MBSM.DAL.AccountType.enumCheckCompany);
        _AccountType.Add(HZ.MBSM.DAL.AccountType.enumCompany);
        _AccountType.Add(HZ.MBSM.DAL.AccountType.enumComapanyRG);
        if (HZ.MBSM.BLL.Login.CheckAssert(_AccountType))
        {


            if (!IsPostBack)
            {
                Db db = new Db();
                System.Data.IDataReader dr;
                strSql = "select * from companygmp where id=" + Id;
                dr = db.DataReader(strSql);
                while (dr.Read())
                {
                    txtAccountId.Text = SysFun.ToTrim(dr["accountid"]);
                    txtAccountId.Visible = false;
                    txtGmpCode.Text = SysFun.ToTrim(dr["gmpcode"]);
                    txtGmpEndDate.Text = SysFun.ToTrim(dr["gmpenddate"]);
                    txtGmpRange.Text = SysFun.ToTrim(dr["gmprange"]);
                    txtGmpStarDate.Text = SysFun.ToTrim(dr["gmpstardate"]);
                }
                dr.Close();
                dr.Dispose();
                db.Close();

            }
        }

    }
    protected void BtnSave_Click(object sender, EventArgs e)
    {
        string Id, AccountId, GMPCode, GMPSatrDate, GMPEndDate, GMPRange;
        HZ.MBSM.Model.Account _Account = (HZ.MBSM.Model.Account)Session["Account"];
        if (_Account != null)
        {
            Id = SysFun.IsSQL(SysFun.ToTrim(MsgBox.JieMi_Decrypt(Request.QueryString["ID"])));
            AccountId = SysFun.ToTrim(txtAccountId.Text);
            GMPCode = SysFun.ToTrim(txtGmpCode.Text);
            GMPEndDate = SysFun.ToTrim(txtGmpEndDate.Text);
            GMPRange = SysFun.ToTrim(txtGmpRange.Text);
            GMPSatrDate = SysFun.ToTrim(txtGmpStarDate.Text);
            string strSql = "update   companygmp set accountid='" + AccountId + "',gmpcode='" + GMPCode + "',gmpstardate='" + GMPSatrDate
                + "',gmpenddate='" + GMPEndDate + "',gmprange='" + GMPRange + "' where id=" + Id;
            Db db = new Db();
            db.Command(strSql);
            db.Close();
            Response.Write("<script>alert('保存成功！！！');</script>");
            //HZ.MBSM.Model.Account _Account = (HZ.MBSM.Model.Account)Session["Account"];
            HZ.MBSM.BLL.LogManage.RecordLoginDetail(_Account.AccountName, Request.UserHostAddress, "更新", "companygmp", strSql, "../Magage/CompanyGMPUpdate.aspx");

        }
        else
        {
            Response.Write("<script language=JavaScript>alert('您无权修改企业GMP信息！！！');</script>");
        }
        Response.Write("<script>window.opener.location.reload();window.close();</script>");

    }
}
